namespace RPG.Domain.Character
{
    public class Level : ValueObject
    {
        public int Value { get; }
        public const int MaxLevel = 99;

        public Level(int value)
        {
            if (value < 1 || value > MaxLevel)
                throw new DomainException($"Level must be between 1 and {MaxLevel}");
                
            Value = value;
        }

        public Level Increase()
        {
            if (Value >= MaxLevel)
                throw new DomainException($"Character is already at max level {MaxLevel}");
                
            return new Level(Value + 1);
        }

        public static Level Initial => new Level(1);
    }
}
